#pragma once
#include <iostream>
#include "SDL_mixer.h"

class SDLAudio
{
#pragma region SINGLETON
public:
	static SDLAudio* GetInstance()
	{
		if(instance == nullptr)
		{
			instance = new SDLAudio();
		}
		return instance;
	}
	static void Kill()
	{
		delete instance;
		instance = nullptr;
	}
private:
	static SDLAudio* instance;

	SDLAudio();
	SDLAudio(const SDLAudio& r);
	~SDLAudio();

	SDLAudio& operator=(const SDLAudio& r);
#pragma endregion
private:
	int audio_rate;
	Uint16 audio_format;
	int audio_channels;
	int audio_buffers;

public:
	static const int LOOP_FOREVER = -1;
	static const int BASE_VOLUME = 128;
	static enum SoundRegion { STEREO, LEFT, RIGHT, LOOP };

	void Init();

	void PlayMusic(Mix_Music* music);
	void PlayMusic(Mix_Music* music, int loop);
	void PlaySound(Mix_Chunk* sound, SoundRegion region);
	void StopMusic();

	int GetVolume() { return Mix_VolumeMusic(-1); }
	void SetVolume(int value) { Mix_VolumeMusic(value); }
};

